package Day25;

import java.util.Scanner;

/**
 * Creat with IntelliJ IDEA
 * Description
 * User: mamba24
 * Date: 2022-10-16
 * Time: 19:35
 * To BE A Better Person-2020-3-2
 */
public class TestDemo2 {
    private static int SumDig(int num){
        int sum=0;
        while(num > 0){
            sum+=num%10;
            num/=10;
        }
        return sum;
    }
    private static int fun(int num){
        if(num < 10){
            return num;
        }else{
            int temp=SumDig(num);
            return fun(temp);
        }
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int num = sc.nextInt();
        int ret=fun(num);
        System.out.println(ret);
    }
}
